package com.qkl.xiatang.app.dto.task;

import lombok.Data;

import java.text.SimpleDateFormat;
import java.util.Date;

@Data
public class TaskTimeVO {

    private Integer totalCount;

    private Integer finishCount;

    private Date minTime;

    private Date maxTime;

    public boolean finishFirst(){
        return Integer.valueOf(1).equals(finishCount);
    }

    public boolean finishAll(){
        if(null != totalCount && totalCount > 0 ){
            return totalCount.equals(finishCount);
        }
        return false;
    }

    public String showTimeRange(){
        return this.timeRange(new SimpleDateFormat("HH:mm"));
    }

    public String showWeighTimeRange(){
        return this.timeRange(new SimpleDateFormat("dd日HH:mm"));
    }

    private String timeRange(SimpleDateFormat format){
        String result = "";
        if(null != minTime){
            result = format.format(minTime);
        }
        result = result + "~";
        if(null != maxTime){
            result = result + format.format(maxTime);
        }
        return result;
    }

}
